package drds.binlog.common;

import drds.common.Author;

/**
 * 严格控制模型
 */
@Author(name = Authors.LI_YANG)
public abstract class AbstractLifeCycle implements LifeCycle
{
    protected volatile boolean running = false; // 是否处于运行中

    public void start()
    {
        if (running)
        {
            throw new BinlogException(this.getClass().getName() + " has startup , don't repeat start");
        }
        running = true;
    }

    public void stop()
    {
        if (!running)
        {
            throw new BinlogException(this.getClass().getName() + " isn't start , please check");
        }
        running = false;
    }

    public boolean isRunning()
    {
        return running;
    }
}
